module.exports = function ($scope, $modal, $resource, toaster) {
	

	$scope.load = function(pageNo){
		var para = {
			'name': $scope.searchform.name,
			'code': $scope.searchform.code,
			'pageNo': pageNo,
		 	'pageSize': $scope.itemsPerPage
		};
		$resource('/api/as/tc/placeview/list', {}, {}).save(para,function (res) {
			if (res.errcode !== 0) {
				toaster.error({title: '', body: '查询景区列表失败'})
				return;
			}
			$scope.list = res.data.results;
			$scope.totalItems = res.data.totalRecord;
			$scope.currentPage = pageNo;
		});

	};
	
	init();
	//初始化机构列表
	function init() {
		$scope.searchform = {
			view_type: {'J':'景区', 'M':'商户', 'H':'酒店'}
		};
		$scope.currentPage = 1
		$scope.itemsPerPage = 10;
		$scope.load(1);
		$resource('/api/as/sc/dict/getDictInfoList', {}, {}).save({'type':'place_activities'}, function(res){
			if (res.errcode === 0) {
				$scope.activities = res.data;
			} else {
				toaster.error({title: '', body: '加载活动列表失败'});
			}
		});
	}


	$scope.setAct = function(obj){
        var modalInstance = $modal.open({
          template: require('../views/setPlaceAct.html'),
          controller: 'setPlaceAct',
          size: 'lg',
          resolve: {
			place : function(){
                return obj;
            },
			activities : function(){
                return $scope.activities;
            }
          }
        });
        modalInstance.result.then(function (result){
			obj.activities = result;
        });
    };




};